package com.dc.base.ui.activity

import android.view.LayoutInflater
import android.view.View
import androidx.viewbinding.ViewBinding
import com.dc.base.ext.inflateBindingWithGeneric
import com.dc.base.vm.BaseViewModel
import java.lang.reflect.ParameterizedType

abstract class BaseVmVbActivity<VM: BaseViewModel, VB: ViewBinding> : BaseVmActivity<VM>(){

    protected lateinit var mViewBinding: VB

    override fun layoutId(): Int = 0

    override fun initDataBind(): View? {
//        val type = javaClass.genericSuperclass as ParameterizedType
//        val aClass = type.actualTypeArguments[1] as Class<*>
//        val method = aClass.getDeclaredMethod("inflate", LayoutInflater::class.java)
//        mViewBinding = method.invoke(null, layoutInflater) as VB
        mViewBinding = inflateBindingWithGeneric(layoutInflater)
        return mViewBinding.root
    }
}